﻿Imports DigitalRune.Windows.TextEditor.Highlighting
Public Class IniEditForm

  Private _text As String

  Private Sub IniEditForm_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
    TextEditorControl.Location = New Point(0, 26)
    TextEditorControl.Size = New Size(Me.Width - 8, Me.Height - 54)
  End Sub

  Private Sub IniEditForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    LoadIni()
    TextEditorControl.Document.HighlightingStrategy = HighlightingManager.Manager.FindHighlighter("ini")
    TextEditorControl.ForeColor = Color.Green
    TextEditorControl.Font = New Font("Lucida Console", 8, FontStyle.Bold)
  End Sub

  Private Sub LoadIni()
    _text = System.IO.File.ReadAllText("config.ini")
    TextEditorControl.Text = _text
    Refresh()
  End Sub

  Private Sub WriteIni()
    System.IO.File.WriteAllText("config.ini", TextEditorControl.Text)
  End Sub

  Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
    WriteIni()
  End Sub

  Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
    LoadIni()

  End Sub
End Class